import { Prisma } from '@prisma/client';
import { Transform } from 'class-transformer';
import { IsDefined, IsNotEmptyObject } from 'class-validator';
import { BaseDto, BaseFindDto, BaseQueryDto } from './base.dto';

export class MessageCreateDto extends BaseDto<Prisma.MessageCreateInput> {}

export class MessageUpdateDto extends BaseDto<Prisma.MessageUpdateInput> {
  @IsDefined({ message: '条件必填' })
  @IsNotEmptyObject({ nullable: false }, { message: '条件参数必填' })
  where: Prisma.MessageWhereUniqueInput;
}

export class MessageRemoveDto {
  @IsDefined({ message: 'ID必填' })
  @Transform(({ value }) => Number(value))
  id: number;
}

export class MessageFindDto extends BaseFindDto<
  Prisma.MessageWhereUniqueInput,
  Prisma.MessageSelect
> {}

export class MessageQueryDto extends BaseQueryDto<Prisma.MessageWhereUniqueInput> {}

export class MessageListDto extends BaseQueryDto<Prisma.MessageWhereUniqueInput> {
  type?: number;
}
